<!-- 标头--task有使用 -->
<template>
  <div class="edit-dropdown-wrap">
    <div class="edit-dropdown-header" @click="changeDropdown">
      {{ props.dropdownTitle }}
      <px-icon>
        <ArrowUp v-show="isDropdown" />
        <ArrowDown v-show="!isDropdown" />
      </px-icon>
    </div>
    <div v-show="isDropdown">
      <slot name="content" />
    </div>
    <div class="edit-dropdown-btn">
      <slot name="btn" />
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, watchEffect } from "vue";

const props = withDefaults(
  defineProps<{
    dropdownTitle: string;
    dropdown?: boolean;
  }>(),
  {
    dropdown: true
  }
);
const isDropdown = ref(true);
watchEffect(() => {
  isDropdown.value = props.dropdown;
});

const changeDropdown = () => {
  isDropdown.value = !isDropdown.value;
};

const openDown = () => {
  isDropdown.value = true;
};
// 暴露出该方法用于将下拉框叠起来
defineExpose({
  openDown
});
</script>
<style lang="scss" scoped>
.edit-dropdown-wrap {
  position: relative;

  .edit-dropdown-header {
    display: flex;
    align-items: center;
    height: 46px;
    font-size: 16px;
    font-weight: bold;
    line-height: 46px;
    color: rgb(0 0 0 / 80%);
    cursor: pointer;
    border-radius: 4px 4px 0 0;

    .px-icon {
      margin-left: 8px;
      font-size: 16px;
    }
  }

  .edit-dropdown-btn {
    position: absolute;
    top: 0;
    right: 24px;
    height: 40px;
    line-height: 40px;
  }
}
</style>
